/*
 * @Description: 
 * @Version: 2.0
 * @Autor: ftt
 * @Date: 2022-06-11 09:49:29
 * @LastEditors: ftt
 * @LastEditTime: 2022-06-11 09:52:21
 */

enum HttpBaseUrlEnum {
  /// 通用url
  normalUrl,

  /// 不同业务的url
  urlNew,
}

enum HttpEnvironEnmu {
  /// 开发环境
  debug,

  /// 预发布环境
  release
}

class HttpNormalConfig {
  static String baseUrl = configbaseUrl(
    urlEnum: HttpBaseUrlEnum.urlNew,
    environEnmu: environ,
  );

  static HttpEnvironEnmu environ = HttpEnvironEnmu.release;
  /*
   * @description:获取url 
   * @param {*}
   * @return {*}
   */
  static conFigNetWorkPath({
    required String path,
    HttpBaseUrlEnum urlEnum = HttpBaseUrlEnum.normalUrl,
  }) {
    String baseurl = configbaseUrl(urlEnum: urlEnum, environEnmu: environ);
    return baseurl + path;
  }

  /*
   * @description: 获取baseUrl 
   * @param {*}
   * @return {*}
   */
  static configbaseUrl({
    HttpBaseUrlEnum urlEnum = HttpBaseUrlEnum.normalUrl,
    HttpEnvironEnmu environEnmu = HttpEnvironEnmu.debug,
  }) {
    String baseUrl = "";
    switch (environEnmu) {
      case HttpEnvironEnmu.debug:
        baseUrl = configDebugBaseUrl(urlEnum: urlEnum);
        break;
      case HttpEnvironEnmu.release:
        baseUrl = configReleaseBaseUrl(urlEnum: urlEnum);
        break;
      default:
    }
    return baseUrl;
  }

  /*
   * @description: 获取开发环境baseUrl
   * @param {*}
   * @return {*}
   */
  static configDebugBaseUrl(
      {HttpBaseUrlEnum urlEnum = HttpBaseUrlEnum.normalUrl}) {
    String url = "";
    switch (urlEnum) {
      case HttpBaseUrlEnum.normalUrl:
        url = "https://test.hmchefu.cn";
        break;
      case HttpBaseUrlEnum.urlNew:
        url = "https://apitest.hmchefu.cn";
        break;
      default:
    }
    return url;
  }

  /*
   * @description: 获取预发布环境baseurl
   * @param {*}
   * @return {*}
   */
  static configReleaseBaseUrl(
      {HttpBaseUrlEnum urlEnum = HttpBaseUrlEnum.normalUrl}) {
    String url = "";
    switch (urlEnum) {
      case HttpBaseUrlEnum.normalUrl:
        url = "https://www.hmchefu.cn";
        break;
      case HttpBaseUrlEnum.urlNew:
        url = "https://api.hmchefu.cn";
        break;
      default:
    }
    return url;
  }
}
